Skip to content

Comments

Patch create dispatch#384

Merged
S1ro1 merged 3 commits intomainfrom
patch-create-dispatch
Dec 19, 2025
Merged

Patch create dispatch#384
S1ro1 merged 3 commits intomainfrom
patch-create-dispatch

Conversation

@S1ro1
Copy link
Member

@S1ro1 S1ro1 commented Dec 19, 2025

No description provided.

Copilot AI review requested due to automatic review settings December 19, 2025 07:07
@S1ro1 S1ro1 merged commit e1928a3 into main Dec 19, 2025
3 of 7 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a patched version of the GitHub library's create_dispatch method to customize the workflow dispatch behavior. The patch is implemented as a standalone function that replicates the dispatch functionality with modifications.

Key changes:

  • Added patched_create_dispatch function that mimics the GitHub library's workflow dispatch method
  • Updated the trigger method to use the patched version instead of calling the library's built-in method
  • Added necessary imports for GitHub library types (github, NotSet, Opt)
Comments suppressed due to low confidence (3)

src/libkernelbot/launchers/github.py:196

  • Using assert statements for input validation is not recommended in production code, as assertions can be disabled with Python's -O optimization flag. Consider replacing these assertions with proper validation that raises TypeError or ValueError exceptions to ensure input validation always occurs.
    assert (
        isinstance(ref, github.Branch.Branch)
        or isinstance(ref, github.Tag.Tag)
        or isinstance(ref, github.Commit.Commit)
        or isinstance(ref, str)
    ), ref
    assert inputs is NotSet or isinstance(inputs, dict), inputs

src/libkernelbot/launchers/github.py:296

  • The noqa: E501 comment is used to suppress line length warnings. Consider breaking this into multiple lines for better readability instead of suppressing the linting rule.
        success = await asyncio.to_thread(

src/libkernelbot/launchers/github.py:189

  • The patched_create_dispatch function lacks documentation explaining why this patch is necessary instead of using the library's built-in create_dispatch method. Consider adding a docstring or comment that explains what issue this patch addresses in the original implementation.
def patched_create_dispatch(
    workflow: Workflow,
    ref: github.Branch.Branch | github.Tag.Tag | github.Commit.Commit | str,
    inputs: Opt[dict] = NotSet,
) -> bool:
    """
    :calls: `POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches <https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event>`_
    """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +209 to 212
return status == 200 or status == 204



Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function returns a boolean indicating success based only on status codes 200 or 204, but returns False for all other status codes without providing any information about what went wrong. Consider logging the actual status code when it's not 200 or 204, or raising an exception with details about the failure to help with debugging when workflow dispatch fails.

Suggested change
return status == 200 or status == 204
if status == 200 or status == 204:
return True
logger.error(
"Workflow dispatch failed for '%s' (ref=%s) with HTTP status %s",
getattr(workflow, "path", workflow),
ref,
status,
)
return False

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant